package com.tulingxueyuan.mall.modules.pms.controller;

import com.tulingxueyuan.mall.common.api.CommonResult;
import com.tulingxueyuan.mall.dto.ContentDTO;
import com.tulingxueyuan.mall.dto.HomeMenusBannerDTO;
import com.tulingxueyuan.mall.dto.HomeMenusDTO;
import com.tulingxueyuan.mall.dto.ProductDTO;
import com.tulingxueyuan.mall.modules.pms.model.PmsProduct;
import com.tulingxueyuan.mall.modules.pms.model.PmsProductCategory;
import com.tulingxueyuan.mall.modules.pms.service.PmsProductCategoryService;
import com.tulingxueyuan.mall.modules.pms.service.PmsProductService;
import com.tulingxueyuan.mall.modules.sms.model.SmsHomeAdvertise;
import com.tulingxueyuan.mall.modules.sms.service.SmsHomeAdvertiseService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = "MenuController",description = "PC主页控制器")
@RequestMapping("/home")
public class MenuController {
    @Resource
    private PmsProductCategoryService pmsProductCategoryService;

    @GetMapping("/productCateList/0")
    public CommonResult<List<HomeMenusDTO>> getMenus(){
        List<HomeMenusDTO> list =  pmsProductCategoryService.getMenus();
        return CommonResult.success(list);
    }
    @GetMapping("/content")
    public CommonResult<ContentDTO> getContent(){
        ContentDTO contentDTO = new ContentDTO();
//        轮播图
        List<SmsHomeAdvertise> list =  pmsProductCategoryService.getContent();
        List<ProductDTO> productDTOList =  pmsProductCategoryService.getHomeProduct();
        contentDTO.setAdvertiseList(list);
        contentDTO.setProductDTOList(productDTOList);

        return CommonResult.success(contentDTO);
    }
}
